﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Module;
using DLL;

namespace BLL
{
    public class BUserPaper
    {
        #region 字段

        private DUserPaper APP = new DUserPaper();//数据操作对象
        private static BUserPaper instance;

        #endregion

        #region 公共接口
        /// <summary>
        /// 取得
        /// </summary>
        /// <returns>DUserPaper对象</returns>
        public static BUserPaper getInstance()
        {
            if (instance == null)
            {
                instance = new BUserPaper();
            }
            return instance;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userProfileInfo"></param>
        /// <returns></returns>
        public bool Insert(UserPaperInfo paperInfo)
        {
            if (paperInfo == null || paperInfo.UserPassportId == 0)
                return false;
            return APP.Insert(paperInfo);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="paperInfo"></param>
        /// <returns></returns>
        public bool Update(UserPaperInfo paperInfo)
        {
            if (paperInfo == null || paperInfo.UserPassportId == 0)
                return false;
            return APP.Update(paperInfo);

        }

        /// <summary>
        /// 根据文章Id获取文章
        /// </summary>
        /// <param name="paperId"></param>
        /// <returns></returns>
        public UserPaperInfo GetPaperInfo(long paperId)
        {
            if (paperId == 0 || paperId.ToString().Length != 18)
                return null;
            return APP.GetPaperInfo(paperId);

        }


        /// <summary>
        /// 获取所有文章
        /// </summary>
        /// <returns></returns>
        public List<UserPaperInfo> GetAllPage()
        {
            return APP.GetAllPage();
        }

         /// <summary>
        /// 根据是否是BSS获取所有的文章，包括状态不可用的
        /// </summary>
        /// <param name="isBBS"></param>
        /// <returns></returns>
        public List<UserPaperInfo> GetPageByIsBBS(long isBBS)
        {

            return APP.GetPageByIsBBS(isBBS);
        }

         /// <summary>
        /// 获取新帖子
        /// </summary>
        /// <returns></returns>
        public List<UserPaperInfo> GetPageNewBBS()
        {
            return APP.GetPageNewBBS();
        }
        /// <summary>
        /// 获取热帖
        /// </summary>
        /// <returns></returns>
        public List<UserPaperInfo> GetPageHotBBS()
        {
            return APP.GetPageHotBBS();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="paperId"></param>
        /// <returns></returns>
        public int Delete(long paperId)
        {
            if (paperId == 0 || paperId.ToString().Length != 18)
                return 0;

            return APP.Delete(paperId);
        }
        #endregion
    }
}
